<template>
	<view class="content ml20 mr20">
		<view class="dis_sb mt60 mb40 ml20 mr20">
			<view class="line26">
				<view class="f34 clo-navyBlue" >审核管理</view>
				<view class="clo-gray f24">审核的内容包含原始数据和修改后数据</view>
			</view>
			<image src="/static/pic5.png" mode="widthFix" class="pic"></image>
		</view>

		<view class=" rad25 bgfff pt10 pb20 main">
            <mescroll-uni top="0" :bottom="0" :fixed="false" height="70%" @init="mescrollInit" @down="downCallback" @up="getListFn" :down="mescrollData.downOption" :up="mescrollData.upOption">
			<view  v-for="(item, index) in dataList" class="w100 pl20 pr20 bs  pt10 pb10 dis_sb ">
				<view class="line18 f28">
					<view class="tit mb10 f30">{{ item.car_code || '无' }}</view>
					<view ><text class="iconfont pr10">&#xe784;</text>卸货日期：<text class="clo-999">{{ item.unload_date }}</text></view>
					<view><text class="iconfont  pr10">&#xe62e;</text>卸车单位：<text class="clo-999">{{ item.unload_unit_name || '无'}}</text></view>
				</view>
				<button class="bbg " @click="tapAudit(item.id)">立即审核</button>

			</view>
            </mescroll-uni>
		</view>
	</view>
</template>
<script setup>
import { ref, reactive, toRefs, onMounted, computed, onUnmounted, getCurrentInstance } from 'vue'
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
import { onLoad, onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import { redirect } from '@/utils/common'
import { getAuditList } from '@/utils/api'
const { proxy } = getCurrentInstance();
proxy.$checkUserType();
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom);

onMounted(() => {
})
const dataList = ref([])

onShow(() => {
    console.log('audit onShow')
    uni.$off('refreshAudit');
    //获取传值
    uni.$on('refreshAudit', function (data) {
        dataList.value = [];
        console.log('refreshAudit')
        getMescroll().resetUpScroll();
    })
})
const mescrollData = reactive({
    downOption: {},
    upOption: {
        page: {
            size: 10 // 每页数据的数量
        },
        noMoreSize: 5, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看
        empty: {
            tip: '~ 暂无数据 ~' // 提示
        }
    }
})

const getListFn = (mescroll) => {

    let data = {
        page: mescroll.num,
        pageSize: mescroll.size,
    };
    let showLoading = false;
    if (mescroll.num == 1) {
        showLoading = true;
    }
    getAuditList(data, showLoading).then((res) => {
        let curPageData = res.data.order_list || [];
        // let totalSize = res.data.count;
        //设置列表数据
        if (mescroll.num == 1) {
            dataList.value = [];
        }
        dataList.value = dataList.value.concat(curPageData);
        mescroll.endSuccess(curPageData.length);
        // mescroll.endBySize(curPageData.length, totalSize);
    }).catch(() => {
        mescroll.endErr(); // 请求失败, 结束加载
    })
}
const tapAudit=(id)=>{
    uni.navigateTo({
        url: '/pages/index/auditDetail?id='+id
    })
}
</script>

<style>
	.pic {width: 180rpx;}
	.tit {padding-left: 20rpx;}
	.tit::after {top: 12%; left: 0;}
	.main {height: 70vh; overflow-y: auto;}
	.bbg {width: 25%;}
	.w100 {border-bottom: 10rpx solid #eee;}
</style>
